/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.math.BigInteger;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Carito
 */
@Entity
@Table(name = "PERMISO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Permiso.findAll", query = "SELECT p FROM Permiso p"),
    @NamedQuery(name = "Permiso.findByIdpermiso", query = "SELECT p FROM Permiso p WHERE p.idpermiso = :idpermiso"),
    @NamedQuery(name = "Permiso.findByEnHorarioDisponible", query = "SELECT p FROM Permiso p WHERE p.enHorarioDisponible = :enHorarioDisponible")})
public class Permiso implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "IDPERMISO")
    private BigInteger idpermiso;
    @Column(name = "EN_HORARIO_DISPONIBLE")
    private Character enHorarioDisponible;
    @JoinColumns({
        @JoinColumn(name = "IDUSUARIO", referencedColumnName = "IDUSUARIO"),
        @JoinColumn(name = "IDEMPRESA", referencedColumnName = "IDEMPRESA")})
    @ManyToOne(fetch = FetchType.EAGER)
    private Usuario usuario;
    @OneToOne(mappedBy = "idpermiso", fetch = FetchType.EAGER)
    private Dato dato;

    public Permiso() {
    }

    public Permiso(BigInteger idpermiso) {
        this.idpermiso = idpermiso;
    }

    @XmlAttribute
    public BigInteger getIdpermiso() {
        return idpermiso;
    }

    public void setIdpermiso(BigInteger idpermiso) {
        this.idpermiso = idpermiso;
    }

    @XmlElement
    public Character getEnHorarioDisponible() {
        return enHorarioDisponible;
    }

    public void setEnHorarioDisponible(Character enHorarioDisponible) {
        this.enHorarioDisponible = enHorarioDisponible;
    }

    @XmlElement
    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

    @XmlElement
    public Dato getDato() {
        return dato;
    }

    public void setDato(Dato dato) {
        this.dato = dato;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idpermiso != null ? idpermiso.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Permiso)) {
            return false;
        }
        Permiso other = (Permiso) object;
        if ((this.idpermiso == null && other.idpermiso != null) || (this.idpermiso != null && !this.idpermiso.equals(other.idpermiso))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Permiso[ idpermiso=" + idpermiso + " ]";
    }
    
}
